from datetime import timedelta
from redis import StrictRedis
import logging


# 创建配置信息
class Config(object):
    DEBUG = True
    SECRET_KEY = 'FQIFJ(&Y72HEUIIU2L'

    # 数据库信息配置
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:mysql@localhost:3306/information18'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 设置数据库自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 配置redis信息
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 配置session信息
    SESSION_TYPE = 'redis'
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)

    # 配置csrf信息,只需要导入类和用CSRFProtect保护app即可

    # 配置log信息
    LEVEL_NAME = logging.DEBUG

# 开发环境信息配置
class DevelopConfig(Config):
    pass

# 生产环境信息配置
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR
# 测试环境配置
class TestConfig(Config):
    TESTING = True

# 对外提供访问入口
config_dict = {
    'develop':DevelopConfig,
    'product':ProductConfig,
    'test':TestConfig
}






